﻿<%@ Page Language="C#" MasterPageFile="~/source/masterpage/base.Master" AutoEventWireup="true" CodeBehind="InvoicesProductManagement.aspx.cs" Inherits="QLK.Web.InvoicesProductManagement" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script language="javascript">
     
      function SelectAllCheckboxesSpecific(spanChk)
       {
           var IsChecked = spanChk.checked;
           var Chk = spanChk;
              Parent = document.getElementById('GriPhuongtien');          
              var items = Parent.getElementsByTagName('input');                         
              for(i=0;i<items.length;i++)
              {               
                  if(items[i].id != Chk && items[i].type=="checkbox")
                  {           
                      if(items[i].checked!= IsChecked)
                      {    
                          items[i].click();    
                      }
                  }
              }            
       }
     
     function SelectAllCheckboxes(spanChk)
     {
           var oItem = spanChk.children;
           var theBox= (spanChk.type=="checkbox") ? spanChk : spanChk.children.item[0];
           xState = theBox.checked;
           elm = theBox.form.elements;

           for(i = 0;i < elm.length; i++)
             if(elm[i].type == "checkbox" && elm[i].id != theBox.id)
             {
               if(elm[i].checked != xState) elm[i].click(); 
             }
     }
     
    function HighlightRow(chkB)
    {
     var IsChecked = chkB.checked;           
        if(IsChecked)
          {
           chkB.parentElement.parentElement.style.backgroundColor='#eee8aa'; 
           chkB.parentElement.parentElement.style.color='white';
   
           }
      else
        {
          chkB.parentElement.parentElement.style.backgroundColor='white';
          chkB.parentElement.parentElement.style.color='black';
        }
    }
    
function MouseEvents(objRef, evt)
{
    var checkbox = objRef.getElementsByTagName("input")[0];
   if (evt.type == "mouseover")
   {
        objRef.style.backgroundColor = "orange";
   }
   else
   {
        if (checkbox.checked)
        {
            objRef.style.backgroundColor = "tomato";
        }
        else if(evt.type == "mouseout")
        {
            if(objRef.rowIndex % 2 != 0)
            {
              
               objRef.style.backgroundColor = "#FFFBD6";
            }
            else
            {
               objRef.style.backgroundColor = "white";
            }
        }
   }
}
    
</script>
<table class="style1">
        <tr>
            <td class="style2">
                &nbsp;</td>
            <td class="style3">
                Invoices_Products</td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Button ID="btnAdd2" runat="server" Text="Add" Width="100px" onclick="btnAdd2_Click" />
            </td>
            <td class="style3">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Button ID="btnDelete" runat="server" Width="100px" Text="Delete" 
                    onclick="btnDelete_Click" />
            </td>
            <td class="style3">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style2">
                &nbsp;</td>
            <td>
                <asp:GridView ID="GridInvoiceProduct" runat="server" 
                    AutoGenerateColumns="False" DataKeyNames="ProductID">
                    <Columns>
                        <asp:TemplateField HeaderText="STT">
                        <ItemTemplate>
                        <%=_iStt++%></ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="InvoiceID" HeaderText="InvoiceID" />
                        <asp:BoundField DataField="Price" HeaderText="Price" />
                        <asp:BoundField DataField="Quantity" HeaderText="Quantity" />
                        <asp:BoundField DataField="TotalValues" HeaderText="TotalValues" />
                        <asp:BoundField DataField="Type" HeaderText="Type" />
                        <asp:TemplateField HeaderText="Edit">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImgEdit" runat="server" 
                                    
                                    CommandArgument="<%# Eval(QLK.Database.Columns.ProductID) %>"
                                    ImageUrl="~/images/edit_desc.gif" onclick="ImgEdit_Click" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Select">
                         <HeaderTemplate>
                                        <input id="chkAll" runat="server" onclick="javascript:SelectAllCheckboxes(this);"
                                            type="checkbox" />
                                    </HeaderTemplate>
                                     <ItemTemplate>
                                        <asp:CheckBox ID="chkSelect" runat="server" onclick="javascript:HighlightRow(this);" />
                                    </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Button ID="btnAdd" runat="server" Text="Add" Width="100px" onclick="btnAdd_Click" />
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>
